Any general purpose processor must provide some mechanism for allowing sequences of instructions to be executed as subroutines. This mechanism must include means for re-directing the flow of control from the sequence of instructions which call, or invoke, the subroutine to the sequence of instructions which comprise the subroutine and means for transferring control back to the calling sequence.
The most common method of implementing subroutining is to have two special instructions which are executable by the processor: Jump-to-Subroutine (JSR) and Return-from-Subroutine (RSR). The JSR instruction stores a pointer which indicates the location to which instruction execution is to return after the subroutine is completed and then transfers control to the subroutine, the starting location of which is typically specified as an argument to the JSR instruction. The RSR instruction simply returns execution to the location specified by the pointer.
The requirement of an RSR instruction at the end of every sequence of instructions which will be used as a subroutine places restrictions on the ability of a programmer to use existing sequences of instructions as subroutines. These restrictions are most important in the context of a processor which uses mask-programmed ROM as the storage medium for programs. Space in such a program store is nearly always in short supply. If a programmer wishes to use a particular sequence of code both as a subroutine and in other contexts, it must either be used always as a subroutine or be duplicated in several places in the control store.
A number of prior art processing machines have mechanisms which make looping in software more efficient. Typically, these mechanisms involve a beginning-of-loop instruction which sets a counter for the desired number of iterations of the loop and an end-of-loop instruction which causes a comparison to be made to determine whether the desired number of iterations is complete with a branch of control flow conditioned on the outcome of the comparison. Every instruction located between the beginning- and end-of-loop instructions forms a part of the sequence executed as a loop. Similar to the conventional subroutining mechanisms described above, these loop mechanisms require special instructions at both the beginning and end of the sequence of instruction to be executed as a loop.